import socket
receiver = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
receiver.bind(("127.0.0.1",40000))
with open("C:\\Users\\11018\\Desktop\\b.txt","wb") as f:
    result = receiver.recvfrom(64*1024)
    f.write(result[0])
    f.flush()
    receiver.close()